package com.ruoyi.listen.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import com.ruoyi.listen.domain.ListenLeader;
import com.ruoyi.listen.service.IListenLeaderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 领导听课Controller
 * 
 * @author yepanpan
 * @date 2021-03-15
 */
@Api("领导听课管理")
@RestController
@RequestMapping("/listen/leader")
public class ListenLeaderController extends BaseController
{
    @Autowired
    private IListenLeaderService listenLeaderService;

    /**
     * 查询领导听课列表
     */
    @ApiOperation("查询领导听课列表")   
    @PreAuthorize("@ss.hasPermi('listen:leader:list')")
    @GetMapping("/list")
    public TableDataInfo list(ListenLeader listenLeader)
    {
        startPage();
        List<ListenLeader> list = listenLeaderService.selectListenLeaderList(listenLeader);
        return getDataTable(list);
    }

    /**
     * 导出领导听课列表
     */
    @ApiOperation("导出领导听课列表")    
    @PreAuthorize("@ss.hasPermi('listen:leader:export')")
    @Log(title = "领导听课", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ListenLeader listenLeader)
    {
        List<ListenLeader> list = listenLeaderService.selectListenLeaderList(listenLeader);
        ExcelUtil<ListenLeader> util = new ExcelUtil<ListenLeader>(ListenLeader.class);
        return util.exportExcel(list, "leader");
    }

    /**
     * 获取领导听课详细信息
     */
    @ApiOperation("获取领导听课详细信息")
    @ApiImplicitParam(name = "id", value = "领导听课ID", required = true, dataType = "int", paramType = "path") 
    @PreAuthorize("@ss.hasPermi('listen:leader:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(listenLeaderService.selectListenLeaderById(id));
    }

    /**
     * 新增领导听课
     */
    @ApiOperation("新增领导听课")
    @PreAuthorize("@ss.hasPermi('listen:leader:add')")
    @Log(title = "领导听课", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ListenLeader listenLeader)
    {
        return toAjax(listenLeaderService.insertListenLeader(listenLeader));
    }

    /**
     * 修改领导听课
     */
    @ApiOperation("修改领导听课")  
    @PreAuthorize("@ss.hasPermi('listen:leader:edit')")
    @Log(title = "领导听课", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ListenLeader listenLeader)
    {
        return toAjax(listenLeaderService.updateListenLeader(listenLeader));
    }

    /**
     * 删除领导听课
     */
    @ApiOperation("删除领导听课")
    @ApiImplicitParam(name = "id", value = "领导听课ID", required = true, dataType = "int", paramType = "path") 
    @PreAuthorize("@ss.hasPermi('listen:leader:remove')")
    @Log(title = "领导听课", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(listenLeaderService.deleteListenLeaderByIds(ids));
    }
}
